<template>
  <el-form :model="form" label-width="120px">
 
        <JmInput
          jmname="用户名"
          v-model="form.username"
          placeholder="sad"
          type="text"
        ></JmInput>
        <JmInput
          jmname="邮箱"
          v-model="form.email"
          placeholder="sad"
          type="text"
        ></JmInput> 
        
        <JmInput
          jmname="昵称"
          v-model="form.nickname"
          placeholder="sad"
          remark="备注" 
          type="text"
        ></JmInput>
        <JmInput
          jmname="密码"
          v-model="form.password"
          placeholder="sad"
          remark="备注"
          type="text"
        ></JmInput> 
<JmEnum
          jmname="状态"
          v-model="form.status"
          :jv="{ 1: '是', 0: '否' }"
          jtype="3"
          br
        ></JmEnum>
  <el-form-item  label="所属组别"> 
  <el-select v-model="form.group_id" placeholder="Select">
    <el-option
      v-for="item in cities"
      :key="item.value"
      :label="item.label"
      :value="item.value"
    >
      <span style="float: left">{{ item.label }}</span>
      <span
        style="
          float: right;
          color: var(--el-text-color-secondary);
          font-size: 13px;
        "
        >{{ item.value }}</span
      >
    </el-option>
  </el-select>  
  </el-form-item>
 

      <el-form-item>
        <el-button type="primary" @click="onSubmit">Create</el-button>
        <el-button>Cancel</el-button>
      </el-form-item>
 
  </el-form>
</template>
 
<script>
import JmInput from "../../../components/form/JmInput.vue";
import JmEnum from "../../../components/form/JmEnum.vue";
export default {
  components: { JmInput, JmEnum },
  data() {
    return {
         form: {
                username: '1',
                nickname: "1",
                password: "",
                avatar: '',
                group_id:"",
                status:'',
            },

      cities :[
               
            ]
    };
  },

  mounted() {
    this.getDataList();
  },
  methods: {
    // 配置信息列表初始化
    async getDataList() {
      try {
        const res = await this.$api.getGroup(); 
        let ccc=[];
       
      res.rows.forEach(element => {
         let cccz=[];
         cccz["value"]=element.id;
         cccz["label"]=element.name;
         ccc.push(cccz);  
      });
      console.log(ccc)
         this.cities=ccc;

      } catch (error) {
        /*console.error(error);*/
      }
    },
    onSubmit() {
      //  console.log(this.form);
      const res = this.$api.addAdmin(this.form);

      console.log(res);
    },
  },
};
</script>
<style>
.demo-tabs > .el-tabs__content {
  padding: 32px;
  color: #6b778c;
  font-size: 32px;
  font-weight: 600;
}
.demo-tabs .custom-tabs-label .el-icon {
  vertical-align: middle;
}
.demo-tabs .custom-tabs-label span {
  vertical-align: middle;
  margin-left: 4px;
}
</style>